<?php
/**
 *
 *
 * @author Zeon <scplay@gmail.com>
 * @date 2018/8/17 10:14
 * @copyright PanxSoft Inc.
 */

namespace App\Services\Repositories\Device;


use App\Models\Customer\DeviceAccount;
use App\Models\Panx\DeviceSpec;

class DeviceSpecRepository
{
    private $deviceSpec;

    public function __construct()
    {
        $this->deviceSpec = new DeviceSpec();
    }

    public static function findByCodeOrDefault(?string $device_spec_code): DeviceSpec
    {
        $devSpecModel = (new self)->deviceSpec;

        if ($device_spec_code) {
            return $devSpecModel->findByCode($device_spec_code) ?: $devSpecModel->default();
        } else {
            return $devSpecModel->default();
        }
    }
}